package applications.studentApplicationForm.ui.lib;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.Observable;

import javax.swing.BoxLayout;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.SwingConstants;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableModel;

import org.objectweb.fractal.fraclet.annotations.Component;
import org.objectweb.fractal.fraclet.annotations.Interface;
import org.objectweb.fractal.fraclet.annotations.Requires;

import applications.studentApplicationForm.fc.api.StudentForm;

@Component(provides = {@Interface(name = "jPanelItf", signature = org.objectweb.fractal.swing.JPanelItf.class), @Interface(name = "observer", signature = java.util.Observer.class), @Interface(name = "jPanelAttributes", signature = org.objectweb.fractal.swing.JPanelAttributes.class), @Interface(name = "uicontainerservice", signature = ontocompo.api.UIContainerService.class), @Interface(name = "ontocompointrospection", signature = ontocompo.api.OntoCompoIntrospection.class)})

public class StudentApplicationFormStudentAcademicRecordButton extends JPanel implements   java.util.Observer, org.objectweb.fractal.swing.JPanelItf, org.objectweb.fractal.swing.JPanelAttributes, ontocompo.api.UIContainerService, ontocompo.api.OntoCompoIntrospection {

	private String uid;
	private org.objectweb.fractal.api.Component c;


	@Requires(name = "studentApplicationFormYearPanel")
	private ontocompo.api.UIContainerService studentApplicationFormYearPanel;

	
	@Requires(name = "studentApplicationFormSemesterPanel")
	private ontocompo.api.UIContainerService studentApplicationFormSemesterPanel;
	
	
	
	@Requires(name = "studentApplicationFormSubjectPanel")
	private ontocompo.api.UIContainerService studentApplicationFormSubjectPanel;
	


	@Requires(name = "studentformdirectoryservice")
	private applications.studentApplicationForm.fc.api.StudentFormDirectoryService studentformdirectoryservice;

	@Requires(name = "studentformdirectoryobservable")
	private ontocompo.api.Observable studentformdirectoryobservable;

	public StudentApplicationFormStudentAcademicRecordButton() {
		super();
		this.uid = "applications.studentApplicationForm.ui.lib.StudentApplicationFormStudentAcademicRecordButton";
		System.out.println(this.toString() + "   created!");

	}

	@Override
	public void init() {

		this.studentformdirectoryobservable.addObserver(this);
		
		
		JPanel panel1 = new JPanel(new BorderLayout());
		JPanel panel2 = new JPanel(new BorderLayout());
		JPanel panel3 = new JPanel(new BorderLayout());

		
		this.studentApplicationFormYearPanel.init();
		this.studentApplicationFormSemesterPanel.init();
		this.studentApplicationFormSubjectPanel.init();
		
		this.setBackground(Color.white);
		panel1.setBackground(Color.white);
		panel2.setBackground(Color.white);
		panel3.setBackground(Color.white);

		


		panel1.add(this.studentApplicationFormYearPanel.getComponentItSelf(), BorderLayout.NORTH);
		panel2.add(this.studentApplicationFormSemesterPanel.getComponentItSelf(),BorderLayout.CENTER);
		panel3.add(this.studentApplicationFormSubjectPanel.getComponentItSelf(),BorderLayout.SOUTH);

		
		this.add(panel1, BorderLayout.NORTH);
		this.add(panel2, BorderLayout.CENTER);
		this.add(panel3, BorderLayout.SOUTH);

		
	}

	@Override
	public JComponent getComponentItSelf() {
		// TODO Auto-generated method stub
		return this;
	}

	@Override
	public void update(Object o) {
		
		this.getParent().validate();  // pour rafraichir la page


		
	}

	protected JLabel createTd(String txt)
	{
		JLabel result = new JLabel(txt);
		result.setFont(result.getFont().deriveFont(Font.PLAIN));
		result.setHorizontalAlignment(SwingConstants.LEFT);

		return result;
	}
	public String toString() {

		return "StudentApplicationFormStudentAcademicRecordButton";
	}


	@Override
	public org.objectweb.fractal.api.Component getFractalComponent() {
		// TODO Auto-generated method stub
		return this.c;
	}

	@Override
	public String getUid() {
		// TODO Auto-generated method stub
		return this.uid;
	}

	@Override
	public void setFractalComponent(org.objectweb.fractal.api.Component c) {
		// TODO Auto-generated method stub
		this.c = c;
	}

	@Override
	public void setUid(String uid) {
		// TODO Auto-generated method stub
		this.uid = uid;
	}

	@Override
	public void update(Observable o, Object arg) {
		// TODO Auto-generated method stub

		StudentForm bk = this.studentformdirectoryservice.getStudentForm();

		if (bk == null){
			return;
		}
		else { 
			this.update(bk);
		}

	}

	
	
	
}
